package com.ruoyi.bizsys.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.bizsys.domain.RealNameAuth;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 实名认证Mapper接口
 *
 * @author african-loan
 * @date 2021-12-30
 */
public interface RealNameAuthMapper extends BaseMapper<RealNameAuth>{

    RealNameAuth selectRealNameAuthByCustNo(String custNo);

    /**
     * 通过客户号修改实名认证表的状态
     * @param custNo
     * @param code
     */
    @Update("update real_name_auth set state=#{code} where cust_no=#{custNo}")
    void updateRealNameAuthToCancellation(@Param("custNo") String custNo, @Param("code") String code);

    /**
     * 查询实名认证状态
     * @param bvnAccount
     * @return
     */
    @Select("select id from real_name_auth where (bvn_account=#{bvnAccount} or account_number=#{accountNumber}) and state=1  LIMIT 1")
    RealNameAuth checkRealName(@Param("bvnAccount") String bvnAccount,@Param("accountNumber") String accountNumber);


    String selectRealNameBvnTotal(String custNo);

    int selectRealNameBvnCnt(String custNo);

    /**
     * 根据custno查询firstName
     * @param custNo
     * @return
     */
    @Select("select first_name from real_name_auth where cust_no=#{custNo}")
    String selectFirstName(@Param("custNo")String custNo);
}
